﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Trauberman.SOChat.StarLeaderboard.Domain;
using Trauberman.SOChat.StarLeaderboard.Models;
using Trauberman.SOChat.StarLeaderboard.Services;

namespace Trauberman.SOChat.StarLeaderboard.Controllers
{
    public class RoomController : Controller
    {
		private IStarService _starSvc;

		public RoomController(IStarService starService)
		{
			this._starSvc = starService;
		}

        public ActionResult Index(int id)
        {
			IEnumerable<StarredMessage> stars = _starSvc.GetStarsByRoom(id);

			var grouping = stars.Where(s => s.User != null).GroupBy(s => s.User);

			return View(new GroupedStarsViewModel(grouping));
        }
    }
}
